﻿using System;
using System.Collections.Generic;
using System.Linq;


class MaximalSequence
{
    static void Main()
    {
        try
        {
            List<int> array = new List<int> {2, 1, 1, 2, 3, 3, 2, 2, 2, 2, 2, 2, 3};
            List<int> array2 = new List<int>();
            List<int> array3 = new List<int>();
            List<int> copyArray = new List<int>();
            int count = 0;
            int copyvalue = 0;           
            int value = 0;
            int number = 0;

            int length = array.Count;
            
            for (int index = 0; index < length; index++)
            {
                if ((index != length - 1) && (array[index] == array[index + 1]))
                {
                    while ((index != length - 1) && array[index] == array[index + 1])
                    {                       
                        number = array[index];
                        index++;
                        count++;                       
                    }
                    count += 1;
                    array2.Add(count);
                    array3.Add(number);
                    count = 0;
                    if (index == (length - 1))
                    {
                        
                        foreach (int numbers in array2)
                        {
                            copyArray.Add(numbers);
                        }
                        array2.Sort();
                        foreach (int num in array2)
                        {
                            value = num;
                        }
                    
                        foreach (int val in copyArray)
                        {
                            if (val == value)
                            {
                                copyvalue = val;
                                index = copyArray.IndexOf(copyvalue);
                                break;
                            }
                        }
                       
                        for (int j = copyvalue; j > 0; j--)
                        {
                            Console.Write("{0}", array3[index] + " ");                       
                        }
                        Console.WriteLine();
                        return;
                    }
                   
                }
                else if (index == (length - 1))
                {
                    copyArray = array2;
                    copyArray.Sort();
                    foreach (int num in copyArray)
                    {
                        value = num;
                    }
                    
                    foreach (int val in array2)
                    {
                        if (val == value)
                        {
                            copyvalue = val;
                            index = array2.IndexOf(copyvalue);
                            break;
                        }
                    }
                    for (int j = copyvalue; j > 0; j--)
                    {
                        Console.Write("{0}", array3[index] + " ");                       
                    }
                    Console.WriteLine();
                    return;
                }
              
            }

        }
        catch (Exception)
        {
            Console.WriteLine("Wrong data!");
            return;
        }
    }
}